/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author HPoi
 */
public class connexion extends javax.swing.JFrame {

    /**
     * Creates new form connexion
     */
    public connexion() 
    {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPasswordField1 = new javax.swing.JPasswordField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        Connecter = new javax.swing.JButton();
        Annuler = new javax.swing.JButton();
        login = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txtpassword = new javax.swing.JPasswordField();
        jLabel6 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();

        jPasswordField1.setText("jPasswordField1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Utilisateur");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        getContentPane().setLayout(null);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Login");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(40, 60, 63, 30);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Password");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(40, 90, 80, 30);

        Connecter.setText("Connecter");
        Connecter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConnecterActionPerformed(evt);
            }
        });
        getContentPane().add(Connecter);
        Connecter.setBounds(50, 195, 110, 30);

        Annuler.setText("Annuler");
        Annuler.setMaximumSize(new java.awt.Dimension(83, 23));
        Annuler.setMinimumSize(new java.awt.Dimension(83, 23));
        Annuler.setPreferredSize(new java.awt.Dimension(83, 23));
        Annuler.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AnnulerActionPerformed(evt);
            }
        });
        getContentPane().add(Annuler);
        Annuler.setBounds(200, 195, 110, 30);

        login.setMinimumSize(new java.awt.Dimension(8, 20));
        getContentPane().add(login);
        login.setBounds(140, 60, 130, 25);
        getContentPane().add(jLabel3);
        jLabel3.setBounds(203, 218, 69, 47);

        jLabel4.setMinimumSize(new java.awt.Dimension(352, 400));
        getContentPane().add(jLabel4);
        jLabel4.setBounds(0, 0, 340, 0);

        txtpassword.setMinimumSize(new java.awt.Dimension(8, 20));
        getContentPane().add(txtpassword);
        txtpassword.setBounds(140, 100, 130, 25);

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/cle.jpg"))); // NOI18N
        jLabel6.setText("jLabel6");
        getContentPane().add(jLabel6);
        jLabel6.setBounds(290, 70, 50, 50);

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/pharmacie_gd.JPG"))); // NOI18N
        jLabel5.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                jLabel5MouseMoved(evt);
            }
        });
        getContentPane().add(jLabel5);
        jLabel5.setBounds(0, -80, 440, 340);

        setSize(new java.awt.Dimension(384, 306));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents
//Bouton Connecter
    private void ConnecterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConnecterActionPerformed
       
        utilisateur ut=new utilisateur();
        if (ut.login(login.getText(), txtpassword.getText()))
        {
             fenetredemarrage fen = new fenetredemarrage();
            fen.setVisible(true);
            this.setVisible(false);
            
        }
        else
        {
            javax.swing.JOptionPane.showMessageDialog(null, "Mot de passe ou le nom d'étuisateur est incorrect", "Erreur d'identification", javax.swing.JOptionPane.INFORMATION_MESSAGE);
           
        }
        
    }//GEN-LAST:event_ConnecterActionPerformed
//Bouton Annuler
    private void AnnulerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AnnulerActionPerformed
    
      this.hide();
    }//GEN-LAST:event_AnnulerActionPerformed

    private void jLabel5MouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel5MouseMoved
        // TODO add your handling code here:
    }//GEN-LAST:event_jLabel5MouseMoved

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(connexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(connexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(connexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(connexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new connexion().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Annuler;
    private javax.swing.JButton Connecter;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JTextField login;
    private javax.swing.JPasswordField txtpassword;
    // End of variables declaration//GEN-END:variables

    private void login() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    
}
